package br.com.unibratec.view;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;
import br.com.unibratec.R;
import br.com.unibratec.negocio.Evento;
import br.com.unibratec.receiver.AgendadorReceiver;
import br.com.unibratec.util.DataUtil;

public class MostrarActivity extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		this.setContentView(R.layout.detalhar);
		this.atualizarDados();
	}

	private void atualizarDados() {
		if (this.getIntent().getSerializableExtra(AgendadorReceiver.EXTRA_EVENTO) != null) {
			Evento evento = (Evento) this.getIntent().getSerializableExtra(AgendadorReceiver.EXTRA_EVENTO);
			((TextView) this.findViewById(R.idDetalhar.textEvento)).setText(evento.getDescricao());
			((TextView) this.findViewById(R.idDetalhar.textData)).setText(DataUtil.dateToString(evento.getData(), "dd/MM/yyyy"));
			((TextView) this.findViewById(R.idDetalhar.textHora)).setText(DataUtil.dateToString(evento.getData(), "HH:mm:00"));

		}
	}

	public void reagendar(View view) {
		Intent intent = new Intent(this, CadastrarEventosActivity.class);
		intent.putExtra(AgendadorReceiver.EXTRA_EVENTO, this.getIntent().getSerializableExtra(AgendadorReceiver.EXTRA_ID_AGENOTIFICACAO));
		intent.putExtra(AgendadorReceiver.EXTRA_EVENTO, this.getIntent().getSerializableExtra(AgendadorReceiver.EXTRA_EVENTO));
		this.startActivity(intent);
		this.finish();
	}

	public void cancelar(View view) {
		this.finish();
	}
}
